<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>文章列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/scroll-bar.css">
    <link rel="stylesheet" href="/static/css/sub-page.css">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_693759_wytlyqhtdtj1nhfr.css">
    <link rel="stylesheet" href="/static/lib/nprogress/nprogress.css">
</head>
<body>
<div class="ok-body">
    <!--面包屑导航区域-->
    <div class="ok-body-breadcrumb">
            <span class="layui-breadcrumb">
                <a><cite>工作流</cite></a>
                <a><cite>我的工作</cite></a>
            </span>
        <a class="layui-btn layui-btn-sm" href="javascript:location.replace(location.href);" title="刷新">
            <i class="layui-icon layui-icon-refresh"></i>
        </a>
    </div>
    <!--模糊搜索区域-->
    <div class="layui-row">
        <form class="layui-form layui-col-md12 ok-search">
            <input class="layui-input" placeholder="开始日期" autocomplete="off" id="startTime">
            <input class="layui-input" placeholder="截止日期" autocomplete="off" id="endTime">
            <input class="layui-input" placeholder="请输入标题" autocomplete="off">
            <button class="layui-btn" lay-submit="" lay-filter="search">
                <i class="layui-icon layui-icon-search"></i>
            </button>
        </form>
    </div>
    <!--工具栏-->
    <script  type="text/html" id="textBar">
        <button class="layui-btn layui-btn-normal" id="batchEnabled">
            <i class="layui-icon layui-icon-ok" style="font-size: 14px"></i> 一键通过
        </button>
        <button class="layui-btn layui-btn-danger" id="batchDisabled">
            <i class="layui-icon layui-icon-close" style="font-size: 14px"></i> 一键驳回
        </button>
        <!--<span>共有数据：<i id="countNum"></i> 条</span>-->
    </script>
    <!--数据表格-->
    <table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
</div>
<!--js逻辑-->
<script src="/static/lib/layui/layui.js"></script>
<script src="/static/lib/nprogress/nprogress.js"></script>

<style type="text/css">
    .layui-table-cell {
        height: 34px;
        line-height: 34px;
    }
</style>
<script th:inline="none">
    // 进度条加载提示
    NProgress.start();
    window.onload = function () {
        NProgress.done();
    }
    // layui相关
    layui.use(['element', 'table', 'form', 'jquery', 'laydate'], function () {
        let element = layui.element;
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let laydate = layui.laydate;

        laydate.render({
            elem: '#startTime',
            type: "datetime"
        });

        laydate.render({
            elem: '#endTime',
            type: "datetime"
        });

        table.render({
            elem: '#tableId',
            url: '/web/act/myWaitingToDo',
            page: true,
            id:'reloadId',
            cellHeight:'34',
            height:'full-130',
            toolbar: '#textBar',
            cols: [[
                {field: '序号',type: 'numbers'},
                {type: 'checkbox'},
                {field: 'description', title: '标题', width: 280 ,align: 'center'},
                {field: 'name', title: '任务名称', width: 260 ,align: 'center'},
                {field: 'executionId', title: '实例节点ID', width: 300 ,align: 'center'},
                {field: 'status', title: '状态', width: 130 ,align: 'center'},
                {title: '操作', width: 280, templet: '#operationTpl', align: 'center'},
                {field: 'id', style:'display:none',width:1}
            ]],
            done: function (res, curr, count) {
                // $("#countNum").text(count);
            }
        });

        form.on('submit(search)', function () {
            layer.msg('正在查询，请稍后...');
            return false;
        });

        table.on('tool(tableFilter)', function (obj) {
            let data = obj.data;
            let layEvent = obj.event;
            let msg;
            if (layEvent === 'pass') {
                msg="yes";
                handle(data.id,msg);

            } else if (layEvent === 'reject') {
                msg="no";
                handle(data.id,msg)
            }
        });

        
        function handle(id,msg) {
            let url = '../../web/act/approval_msg'
            $.ajax({
                url:url,
                data:{'id':id,'msg':msg},
                success:function (res) {
                    if(res.code!=0){
                        layer.alert(res.msg,{icon:2})
                    }else{
                        layer.alert(res.msg,{icon:1})
                    }
                    table.reload("reloadId");
                }
            })
            return false;
        }



    })
</script>
<!--模板-->
<script type="text/html" id="urlTpl">
    <a href="{{d.url}}" target="_blank">{{d.url}}</a>
</script>
<script type="text/html" id="topTpl">
    <input type="checkbox" name="isTop" value="{{d.isTop}}" lay-skin="switch" lay-text="是|否" {{ d.isTop== true ? 'checked' : ''}}>
</script>
<script type="text/html" id="statusTpl">
    <input type="checkbox" name="top" value="{{d.status}}" lay-skin="switch" lay-text="上架|下架" {{ d.status== true ? 'checked' : ''}}>
</script>
<script type="text/html" id="operationTpl">
    <!--<a href="javascript:;" title="编辑" lay-event="edit"><i class="layui-icon">&#xe642;</i></a>-->
    <!--<a href="javascript:;" title="删除" lay-event="del"><i class="layui-icon">&#xe640;</i></a>-->
    <a href="javascript:;" class="layui-btn"  lay-event="pass"> <i class="layui-icon">&#x1005;</i>通过</a>
    <a href="javascript:;" class="layui-btn"  lay-event="reject"><i class="layui-icon">&#x1007;</i>驳回</a>
    <!--<a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>-->
</script>
</body>
</html>
